Skip to content

feat!: #697 added tool input arguments validation#873

Open
ashakirin wants to merge 2 commits intomodelcontextprotocol:mainfrom
ashakirin:feature/697-tools-input-validation
Open

feat!: #697 added tool input arguments validation#873
ashakirin wants to merge 2 commits intomodelcontextprotocol:mainfrom
ashakirin:feature/697-tools-input-validation

Conversation

@ashakirin
Copy link
Copy Markdown
Contributor

Added tool input arguments validation causes Tool Execution Error accordingly SEP-1303.
It is breaking change, because tool input validation is activated by default

… causes tool execution error. Breaking change, because validation is activated by default
@Kehrlann Kehrlann self-assigned this Mar 26, 2026
@Kehrlann Kehrlann added area/server P1 Significant bug affecting many users, highly requested feature v2 labels Mar 26, 2026
Copy link
Copy Markdown
Contributor

@Kehrlann Kehrlann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I'm revisiting this, I'm wondering whether we really want this system property to toggle this on or off.

We're going to ship this in 2.0, let it be a breaking change - after all, servers MUST validate tool inputs.

(And we should probably revisit tool name validation too, then)

@@ -0,0 +1,74 @@
/*
* Copyright 2024-2024 the original author or authors.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright 2024-2024 the original author or authors.
* Copyright 2026-2026 the original author or authors.

@@ -0,0 +1,270 @@
/*
* Copyright 2024-2024 the original author or authors.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright 2024-2024 the original author or authors.
* Copyright 2026-2026 the original author or authors.

* errors are returned as Tool Execution Errors (isError=true) rather than Protocol
* Errors, per MCP specification.
*
* @author Alireza Khoram
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this author tag intended?

@@ -0,0 +1,270 @@
/*
* Copyright 2024-2024 the original author or authors.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright 2024-2024 the original author or authors.
* Copyright 2026-2026 the original author or authors.

}
Map<String, Object> inputSchema = jsonMapper.convertValue(tool.inputSchema(),
new TypeRef<Map<String, Object>>() {
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should leave this marshalling on the hot path. Look at what we've done in DefaultJsonSchemaValidator, there's a schema cache to avoid specifically doing to much of these operations.

Maybe we should have something similar here? Or maybe we should update the JsonSchemaValidator to also validate JsonSchema objects?

@Kehrlann Kehrlann added the waiting for user Waiting for user feedback or more details label Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/server P1 Significant bug affecting many users, highly requested feature v2 waiting for user Waiting for user feedback or more details

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants